Skip to content

fix(control-plane): preserve original-Turn closeout after automatic archival - #8264

Open
cocolord wants to merge 3 commits into
mainfrom
codex/small-kernel-archive-closeout-20261107
Open

cocolord wants to merge 3 commits into
mainfrom
codex/small-kernel-archive-closeout-20261107

Conversation

@cocolord

@cocolord cocolord commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

With 101 Todos, ordinary completion can automatically archive the selected Todo before its original Turn finishes settlement. The later todo complete --no-follow-up then fails with todo_archived, even though completion, writeback and one quota debit are already committed.

This repair lets that archived Todo finish the original terminal phase only after the existing same-Turn fence and exact ordinary-completion receipt checks pass. A local TypeScript helper shares those checks between active and archived paths. Task digest, claim/lease, validation receipt, authority and provider CAS checks remain; archive selection and retention thresholds are unchanged. No archived work is reopened.

The proposal integrates main abf144202 (#8161). Its explicit Goal-scoped acceptance checks remain independent of local Todo completion: a real failing Goal checker stays failed after the local validated Todo completes, archives and closes its original Turn. Neither checker is rerun during terminal closeout/replay, and the original completion time, validation receipt and one debit survive.

101 个 Todo 时,自动归档会让已完成写回和一次扣账的原 Turn 在最终终结时返回 todo_archived。修复复用既有同 Turn fence 与精确父 receipt 校验。集成 #8161 后,新增真实 CLI 案例证明:整体 Goal 检查失败时,局部 Todo 仍可按自身 validator 完成和终结;整体检查继续失败,终结与回放不重复执行 checker 或扣账。

Validation at 12627eff8005b900d8c1b99589de02a8a481a8aa against origin/main (abf144202):

  • Real File/SQLite source-console fixtures complete the 101-Todo lifecycle with an independently verified sum artifact, exact completion/writeback/spend/terminal retries and one debit. Invalid Vision/workspace requests remain rejected.
  • Four real CLI/validator archive cases pass across File/SQLite with and without a failing Goal commitment. Premature settlement, unrelated archived work, another actor/claim/Turn and changed completion intent remain refused.
  • 509 focused TypeScript lifecycle, authority, Goal acceptance, fence and transaction checks pass with a real isolated PostgreSQL connection; zero skips. The first combined run retained 24 PostgreSQL skips without that connection; these were subsequently qualified on the disposable server.
  • 389 real PostgreSQL authority-store integration checks pass on an isolated PostgreSQL 16.15 server, without skips.
  • Control-plane typecheck, staged/exact-head bilingual RFC checks and standard premerge pass: five direct checks plus 17 selected canary/risk/public-boundary checks, zero failures.

The baseline lifecycle failures and the earlier frozen cost comparison remain failures. Earlier fixture assertions used the wrong archive token and the first disposable PostgreSQL startup exceeded the Unix socket path limit; those setup results are preserved separately from the passing qualification.

The paired RFC checkpoint records the proposed repair and latest-main integration. Independent exact-head review and reviewed-repair monolithic-wheel readback remain pending. Installed-host upgrade, interruption/restart, split installation, full R0/V10/R1, M1, context/model composition and complete-cost/adoption acceptance remain open. I3 retains at least one minor release. The same helper is the bounded refactor; no parallel Python owner or new preset/default/provider selection is introduced.

This author proposal does not grant merge authority. No merge into main or installed-host upgrade was performed.

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
cocolord and others added 2 commits November 7, 2026 16:48
…chive-closeout-20261107

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

[P2] 终结时保留归档 Todo 的原验收证据。 已通过验证、写回并扣账一次后,只修改终结命令的 --evidence,File 和 SQLite 都会写入替换后的证据。返回的仍是原验证回执。随后拿原证据重试会得到幂等回放,Todo 回读却仍指向替换后的证据。归档终结应沿用已接受的 evidence,并拒绝不同的证据参数。 证据写入

动机 / Motivation

执行一轮已验收任务的 Agent 需要完成结算,并能在丢失响应后凭原身份取回结果。 在 101 个 Todo 的合成状态下,普通完成会归档当前 Todo。旧版已写回并扣账一次,终结命令仍报 todo_archived。 用原验收证据重试时,修复版在 File 和 SQLite 上都能终结并回放,验证器、写回和扣账各执行一次。 这次验证覆盖源码 CLI 和两个隔离的权威后端。实际宿主采用和完整成本仍待验。 当前提交还允许在终结时替换已归档的验收证据。

改动思路 / Approach

在既有 TypeScript 生命周期里复用同轮校验,只给归档记录补上终结状态。 新增的入口沿用同轮 fence 和普通完成回执。源文本摘要、原 claim、当前权威状态与 provider CAS 继续约束这次写入。无需改变归档阈值或重跑已验收的任务。当前还要约束复用的终结写入,避免把归档前已有的证据覆盖行为带到归档后。 父回执检查

具体改动 / Changes

关键代码讲解

  • readSameTurnCompletionReceipt 从相同 Goal、Todo 和 Turn 找到普通完成回执,并核对原验证。缺失或错配的回执会拒绝。 实现
  • executeCoordinationTodoTerminalLifecycle 在拒绝归档 Todo 前允许原 Turn 的终结通过。同轮写回和扣账仍是前置条件。 归档分支
  • terminalRequestSha 和 terminalTarget 在普通 Turn 模式下沿用旧摘要,摘要没有绑定 evidence。新分支随后进入共用写入,直接使用调用方提交的证据。 摘要 写入

按 abf1442 的 docs/reference/canonical-terminal-review.md 核对 original-turn-chain、premature-closeout 和 receipt-recovery。原证据路径能按顺序终结并回放。普通完成后、写回扣账前仍会拒绝。与 #8161 集成的四种 File/SQLite 对照也通过,整体 Goal 检查失败时,局部 Todo 可以完成,原 Goal 的失败和检查次数均保留。 原契约

对主干的风险 / Risks

同一真实验证器在两种后端各执行一次。原证据对照保留完成时间、归档状态和一次扣账。替换证据的反例也返回通过的旧回执,因此应额外检查权威 Todo 中的证据字段。基线的 active SQLite 路径已有覆盖行为,基线归档路径拒绝写入。本提交把这条写入扩到了归档记录。请在现有 CLI 回归里加仅变更 --evidence 的反例,再验证原命令仍可终结并回放。 现有回归

语义与 CI 对齐

沿用原 completion_turn 和 no_followup,没有新状态值。10 项 CLI、212 项 TypeScript、类型、Ruff 与快速 premerge 均通过。主干 2659e5f 的合并预检及双语检查通过。严格 CQR 因归档证据反例未通过。PostgreSQL 结果来自作者,托管 CI 按策略保留未知。

我的整体评价 / Verdict

原 Turn 的归档终结恢复值得保留。归档终结应沿用已接受的 evidence,并拒绝不同的证据参数。 可以沿用历史指纹,在新归档分支约束证据字段,保留原验证和回放。改动集中在原生 CLI 结算和 Todo 回读。修订后需复测 File 和 SQLite 的精确输入与证据替换。新提交的 Goal 检查对照已经通过,终结证据覆盖仍可复现。实际安装、采用和完整成本仍待单独验收。

English verdict: REQUEST_CHANGES. Keep the original accepted evidence when closing an archived Todo. Both native backends currently let changed evidence overwrite the archived record while replaying the original validation.

@mergify

mergify Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @cocolord.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants